#!/bin/sh

set -- "$HOME/.bash_history" \
	"$HOME/.cache/chromium" \
	"$HOME/.cache/emacs" \
	"$HOME/.cache/locatedb" \
	"$HOME/.cache/qutebrowser" \
	"$HOME/.cache/thumbnails" \
	"$HOME/.config/gtk-2.0" \
	"$HOME/.config/gtk-3.0" \
	"$HOME/.config/qutebrowser/bookmarks" \
	"$HOME/.config/qutebrowser/quickmarks" \
	"$HOME/.esd_auth" \
	"$HOME/.fehbg" \
	"$HOME/.geiser_history.*" \
	"$HOME/.gtk-bookmarks" \
	"$HOME/.guile_history" \
	"$HOME/.lesshst" \
	"$HOME/.local/share/fish" \
	"$HOME/.local/share/qutebrowser" \
	"$HOME/.local/share/webkit" \
	"$HOME/.mpv/watch_later" \
	"$HOME/.mtap.fuseiso" \
	"$HOME/.mu" \
	"$HOME/.pulse-cookie" \
	"$HOME/.python_history" \
	"$HOME/.thumbnails" \
	"$HOME/.tramp_history" \
	"$HOME/.units_history" \
	"$HOME/.wget-hsts" \
	"$HOME/.w3m"

echo "==> Files to be removed (beside trash):"
echo "$@" | sed 's/ /\n/g'
echo
echo "==> Critical data:"
for i in ~/.cache/mail ~/.password-store "$PERSONAL" ~/.ssh/*.pub; do
	[ -e "$i" ] && echo ":: WARNING: Found '$i'."
done
if [ -n "$(gpg --list-secret-keys)" ]; then
	echo ":: WARNING: Found PGP secret keys."
fi

CHOICE="N"
echo
echo ":: WARNING: Please close all applications before proceeding."
echo -n "==> Clean home? (y/N) "
read -r CHOICE
case "$CHOICE" in
Y|y) ;;
*)
	echo "Nothing done."
	exit ;;
esac

echo
echo "==> Empty trash:"
if ! command -v trash-empty >/dev/null 2>&1; then
	echo ":: 'trash-empty' not installed, you must clean other drives manually."
	rm -rvf "$HOME/.local/share/Trash"
else
	trash-empty
fi

echo
echo "==> Delete garbage in $HOME:"
rm -rvf "$@"
